//
// Created by Zhangwj on 2023/9/27.
//

#include "EqExpNode.h"

std::unique_ptr<EqExpNode> EqExpNode::EqExpParser(Parser &parser) {
    //EqExp → RelExp | EqExp ('==' | '!=') RelExp
    //改写为 EqExp -> RelExp { ('==' | '!=') RelExp}
    std::unique_ptr<EqExpNode> eqExpNode = std::make_unique<EqExpNode>();
    eqExpNode->RelExps.push_back(RelExpNode::RelExpParser(parser));
    while (parser.getLexType(0) == LexType::EQL || parser.getLexType(0) == LexType::NEQ) {
        eqExpNode->Ops.push_back(parser.getLexType(0));
        parser.next();
        eqExpNode->RelExps.push_back(RelExpNode::RelExpParser(parser));
    }
    return eqExpNode;
}
